﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Dimok.Shared {
	public partial class FaultContract {

		////////////////////////////////////////////////////////////////////////////////////////////////////
		/// <summary>	Constructor. </summary>
		///
		/// <remarks>	Dimon, 12/21/2010. </remarks>
		///
		/// <param name="exc">	The exc. </param>
		////////////////////////////////////////////////////////////////////////////////////////////////////

		public FaultContract(Exception exc) {
			var mi = Dimok.Common.GetMethod(1);
			List<string> messages = new List<string>() { "Source: " + mi.DeclaringType.Name + "." + mi.Name };
			for (; exc != null; exc = exc.InnerException) {
				FaultType = exc.GetType().Name;
				messages.Add(exc.Message);
			}
			Message = string.Join(Environment.NewLine, messages.ToArray());
		}
	}
}
